package com.info33.platform.config.rabbitMq;


import com.info33.platform.common.util.MQConstantUtil;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 队列配置
 */
@Configuration
public class QueueConfiguration {

    @Autowired
    @Qualifier("defaultDirectExchange")
    private DirectExchange exchange;


    @Bean
    public Queue helloQueue() {
        return new Queue(MQConstantUtil.QUEUE_HELLO_NAME,true,false,false);
    }

    @Bean
    public Queue otherOrderQueue() {
        return new Queue(MQConstantUtil.OTHER_ORDER_NAME,true,false,false);
    }


    @Bean
    public Binding helloBinding() {
        return BindingBuilder.bind(helloQueue()).to(exchange).with(MQConstantUtil.QUEUE_HELLO_NAME);
    }

    @Bean
    public Binding otherOrderBinding() {
        return BindingBuilder.bind(otherOrderQueue()).to(exchange).with(MQConstantUtil.OTHER_ORDER_NAME);
    }


}
